package com.cjl.net;


public class Config {
    private final String method;
    private final int readTimeOut;
    private final int connectTimeOut;
    private final String option;

    public Config(Builder builder) {
        this.method = builder.method;
        this.readTimeOut = builder.readTimeOut;
        this.connectTimeOut = builder.connectTimeOut;
        this.option = builder.option;
    }

    public String getMethod() {
        return method;
    }

    public int getReadTimeOut() {
        return readTimeOut;
    }

    public int getConnectTimeOut() {
        return connectTimeOut;
    }

    public String getOption() {
        return option;
    }

    /**
     * 参数较多时
     */
    public static class Builder{
        private String method;
        private int readTimeOut;
        private int connectTimeOut;
        private String option;

        public Builder() {
            this.method = "GET";
            this.readTimeOut = 5000;
            this.connectTimeOut = 5000;
            this.option = "";
        }

        public Builder method(String val){
            method = val;
            return this;
        }

        public Builder readTimeOut(int val){
            readTimeOut = val;
            return this;
        }

        public Builder connectTimeOut(int val){
            connectTimeOut = val;
            return this;
        }

        public Builder option(String val){
            option = val;
            return this;
        }

        public Config build(){
            return new Config(this);
        }
    }

}
